/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.BrewView;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Barrels")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Barrels.findAll", query = "SELECT b FROM Barrels b"),
    @NamedQuery(name = "Barrels.findByBarID", query = "SELECT b FROM Barrels b WHERE b.barID = :barID"),
    @NamedQuery(name = "Barrels.findByBarDisc", query = "SELECT b FROM Barrels b WHERE b.barDisc = :barDisc"),
    @NamedQuery(name = "Barrels.findByBarVol", query = "SELECT b FROM Barrels b WHERE b.barVol = :barVol"),
    @NamedQuery(name = "Barrels.findByCurrentVol", query = "SELECT b FROM Barrels b WHERE b.currentVol = :currentVol"),
    @NamedQuery(name = "Barrels.findByBarNotes", query = "SELECT b FROM Barrels b WHERE b.barNotes = :barNotes"),
    @NamedQuery(name = "Barrels.findByPastBatches", query = "SELECT b FROM Barrels b WHERE b.pastBatches = :pastBatches"),
    @NamedQuery(name = "Barrels.findByDateFilled", query = "SELECT b FROM Barrels b WHERE b.dateFilled = :dateFilled"),
    @NamedQuery(name = "Barrels.findFilled", query = "SELECT b FROM Barrels b WHERE b.brew IS NOT NULL")})
public class Barrels implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "BarID")
    private Integer barID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "BarDisc")
    private String barDisc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BarVol")
    private float barVol;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CurrentVol")
    private float currentVol;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "BarNotes")
    private String barNotes;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 500)
    @Column(name = "PastBatches")
    private String pastBatches;
    @Column(name = "DateFilled")
    @Temporal(TemporalType.DATE)
    private Date dateFilled;
    @JoinColumn(name = "CurrentBatch", referencedColumnName = "BID", nullable=true)
    @ManyToOne(optional=true)
    private BrewView brew;

    public Barrels() {
    }

    public Barrels(Integer barID) {
        this.barID = barID;
    }

    public Barrels(Integer barID, String barDisc, float barVol, float currentVol, String barNotes, String pastBatches, Date dateFilled) {
        this.barID = barID;
        this.barDisc = barDisc;
        this.barVol = barVol;
        this.currentVol = currentVol;
        this.barNotes = barNotes;
        this.pastBatches = pastBatches;
        this.dateFilled = dateFilled;
    }

    public Integer getBarID() {
        return barID;
    }

    public void setBarID(Integer barID) {
        this.barID = barID;
    }

    public String getBarDisc() {
        return barDisc;
    }

    public void setBarDisc(String barDisc) {
        this.barDisc = barDisc;
    }

    public float getBarVol() {
        return barVol;
    }

    public void setBarVol(float barVol) {
        this.barVol = barVol;
    }

    public BrewView getCurrentBatch() {
        return brew;
    }

    public void setCurrentBatch(BrewView brew) {
        this.brew = brew;
    }

    public float getCurrentVol() {
        return currentVol;
    }

    public void setCurrentVol(float currentVol) {
        this.currentVol = currentVol;
    }

    public String getBarNotes() {
        return barNotes;
    }

    public void setBarNotes(String barNotes) {
        this.barNotes = barNotes;
    }

    public String getPastBatches() {
        return pastBatches;
    }

    public void setPastBatches(String pastBatches) {
        this.pastBatches = pastBatches;
    }

    public Date getDateFilled() {
        return dateFilled;
    }

    public void setDateFilled(Date dateFilled) {
        this.dateFilled = dateFilled;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (barID != null ? barID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Barrels)) {
            return false;
        }
        Barrels other = (Barrels) object;
        if ((this.barID == null && other.barID != null) || (this.barID != null && !this.barID.equals(other.barID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Barrels[ barID=" + barID + " ]";
    }
    
}
